standard_billing_determinants_calculation
Purpose
The purpose of the rule is to calculate billing determinants based on an incoming billing request.
Detailed description
!()[images/standard_billing_determinants_calculation.png]
- Load timeslice groups, if present
- Create ‘determinants’ list to store the values that are calculated throughout the rule
- Calculate billing determinants for interval channels , if they exist:
- If there are any timeslice channles in the request:
- Get holiday calendar information stored in datasource tag. If the tag does not exist, a FLowCancelException is thrown
- Create a mask that defines which timeslices to apply to each timestamp. Mask checks whether timestamp is dst or not, holiday or not, weekend or weekday. Note: holiday takes precedent over weekend/weekday
- Make a pd.DataFrame where each column is a tariff channel, and keep only information relevant to that tariff.
- If split_by_month = True:
- Create sub period per month for the billing period in the request
- For each period requested, calculate determinants and quality
- Sum all intervals in the period, and take the lowest quality status in the period as the determinant's quality status
- Store results in a dict and append to ‘determinants’ list
- If there are any timeslice channles in the request:
- Calculate billing determinants for Pmax channels , if they exist:
- Find max value per month present in the billing period, store it in a pd.DataFrame
- Find max value in the billing period, the quality is set to the lowest quality status in that period. This is done in the pd.DataFrame from step ‘a’
- Store results in a dict and append to ‘determinants’ list
- If split_by_month = True
- Get the max per sub-period, calculated in step ‘a’. Status is set to the min quality status in the period
- Store it in a dict and append to ‘determinants’ list.
- Calculate billing determinants for register channels , if they exist
- If split_by_month = True:
- Create sub period per month for the billing period in the request
- For each period requested, calculate determinants and quality
- Get the value and quality from the timestamp of the end of the sub-period
- Store results in a dict and append to ‘determinants’ list
- If split_by_month = True:
- Store billing information in respective BILLING channel classifier
- Billing channel name is deduced based on determinants information
- Start and end period are added to an annotation
- Flow timestamp is added to the annotation
- If pmax, information on the timestamp of when the Pmax occured is added as an annotation.
- Quality information is added to the Quality_Status DPA
- Channels are saved into self.datasource.id
- Create billing message and add it to the flow properties
- Loop through ‘determinants’ list and add the information to the message dict
- Create a json file from the ‘message’ dict
- Add message to the flow properties with key = self.datasource.id - this is later used to build the message and send it out later